#!/usr/bin/php
<?php

$cmds = array(
    array('msg' => 'Compiling docs ', 'cmd' => 'phpdoc -s on -dn File_CSV_Get -d . -t docs/phpdoc -o HTML:Smarty:PHP > misc/phpdoc_output'),
    array('msg' => 'Uninstalling   ', 'cmd' => 'pear uninstall File_CSV_Get'),
    array('msg' => '+- DELETE pkge ', 'cmd' => 'rm *.tgz'),
    array('msg' => 'Code Sniffing  ', 'cmd' => 'phpcs *.php > misc/phpcs_output'),
    array('msg' => '+- output      ', 'cmd' => 'cat misc/phpcs_output'),
    array('msg' => 'Running Tests  ', 'cmd' => 'cd ../.. && phpunit File > File/CSV/misc/phpunit_output'),
    array('msg' => '+- output      ', 'cmd' => 'cat misc/phpunit_output'),
    array('msg' => 'Compiling XML  ', 'cmd' => 'rm package.xml'),
    array('msg' => '+- Top    XML  ', 'cmd' => 'php -d short_open_tag=Off data/top.xml.php >> package.xml'),
    array('msg' => '+- Files  XML  ', 'cmd' => 'php mk_filelist >> package.xml'),
    array('msg' => '+- Bottom XML  ', 'cmd' => 'cat data/bottom.xml >> package.xml'),
    array('msg' => 'Packaging      ', 'cmd' => 'pear package > misc/pear_package_output'),
    array('msg' => '+- output      ', 'cmd' => 'cat misc/pear_package_output'),
    array('msg' => 'Installing     ', 'cmd' => 'pear install --force *.tgz > misc/pear_install_output'),
    array('msg' => '+- output      ', 'cmd' => 'cat misc/pear_install_output'),
);


$build_log = '';
foreach ($cmds as $task) {
    echo $output = shell_exec($task['cmd']);
    $build_log .= $output;
}

file_put_contents('misc/build_output', $build_log);

?>
